<template>
    <view class="page" :style="themeColor">
    <view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex editAddress_flex_0"    :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
            <view   class='flex flex-wrap align-center justify-between editAddress_fd0_0'     >
            <view   class='flex flex-wrap align-center editAddress_fd0_0_c0'  @tap.stop="handleJumpDiy" data-type="back" data-url="1"   >
        <text class='fu-iconfont2  editAddress_fd0_0_c0_c0' >&#xE794;</text>
</view>
    <view   class='flex flex-wrap align-center'     >
        <text class='editAddress_fd0_0_c1_c0' >编辑地址</text>
</view>
    <view   class='flex align-center justify-end editAddress_fd0_0_c2'  @tap.stop="popupShow1658111180390=true"   >
        <text class='editAddress_fd0_0_c2_c0' >删除</text>
</view>
</view>

        </view>
<view :style="{height: (88+StatusBarRpx)+'rpx'}"  ></view>
<!---添加地址flex布局开始-->
 <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout editAddress_flex_1"   >
            <view   class='flex flex-wrap align-center editAddress_fd1_0'     >
        <text class='editAddress_fd1_0_c0' >标签</text>
    <benben-select-diy ref="showSelectPopup1658109510834" class-name='flex align-center flex' :items.sync="select_adr" v-model="address"  default-type="name" default-label="aid" :allow-cancel='false' type="radio" :disabled='false'  >
    <template v-for = '(item,key0) in select_adr'>
            <view v-if="item.isSelected"  class='flex align-center flex' :key="key0" @tap="$refs.showSelectPopup1658109510834.tapHandle(key0)"     >
        <text class='editAddress_fd1_0_c1_c0_c0' >{{item.name}}</text>
</view>    <view  v-else  class='flex align-center flex' :key="key0" @tap="$refs.showSelectPopup1658109510834.tapHandle(key0)"     >
        <text class='editAddress_fd1_0_c1_c1_c0' >{{item.name}}</text>
</view></template></benben-select-diy>
</view>
    <view   class='flex flex-wrap align-center editAddress_fd1_1'     >
        <text class='editAddress_fd1_1_c0' >收货人</text>
<input class='flex-sub editAddress_fd1_1_c1'  type="text" placeholder="收货人" confirm-type="done" :maxlength="-1" placeholder-style="color:#BFBFBF;font-size:32rpx"  v-model="dataDetails.name" />
    <benben-select-diy ref="showSelectPopup1657267117759" class-name='flex flex' :items.sync="sex" v-model="dataDetails.sex"  default-type="value" default-label="name" :allow-cancel='true' type="radio" :disabled='false'  >
    <template v-for = '(item,key0) in sex'>
            <view v-if="item.isSelected"  class='flex align-center flex editAddress_fd1_1_c2_c0' :key="key0" @tap="$refs.showSelectPopup1657267117759.tapHandle(key0)"     >
        <image class='editAddress_fd1_1_c2_c0_c0' mode="aspectFit"  :src='STATIC_URL+"80.png"'></image>
<text class='editAddress_fd1_1_c2_c0_c1' >{{item.name}}</text>
</view>    <view  v-else  class='flex align-center flex editAddress_fd1_1_c2_c1' :key="key0" @tap="$refs.showSelectPopup1657267117759.tapHandle(key0)"     >
        <image class='editAddress_fd1_1_c2_c1_c0' mode="aspectFit"  :src='STATIC_URL+"99.png"'></image>
<text class='editAddress_fd1_1_c2_c1_c1' >{{item.name}}</text>
</view></template></benben-select-diy>
</view>
    <view   class='flex flex-wrap align-center editAddress_fd1_2'     >
        <text class='editAddress_fd1_2_c0' >联系电话</text>
<input class='flex-sub editAddress_fd1_2_c1'  type="number" placeholder="联系电话" confirm-type="done" :maxlength="11" placeholder-style="color:#BFBFBF;font-size:32rpx"  v-model="dataDetails.mobile" />
</view>
    <view   class='flex flex-wrap align-center editAddress_fd1_3'  @tap.stop="pickerDiy1657266876127=true"   >
        <text class='editAddress_fd1_3_c0' >所在地区</text>
<input class='flex-sub editAddress_fd1_3_c1'  type="text" placeholder="请选择省市区县、乡镇" confirm-type="done" :maxlength="-1" :disabled='true' placeholder-style="color:#BFBFBF;font-size:32rpx"  v-model="dataDetails.address_detail" />
<image class='editAddress_fd1_3_c2' mode="aspectFit"  :src='STATIC_URL+"100.png"'></image>
</view>
    <view   class='flex flex-wrap align-center editAddress_fd1_4'     >
        <view class='flex flex-wrap editAddress_fd1_4_c0'>
<textarea class='flex editAddress_input_fd1_4_c0' confirm-type="done" :placeholder="'请填写详细地址：如道路、门牌号、小区、楼栋号等'" :maxlength="240" placeholder-style="color:#BFBFBF;font-size:28rpx"   v-model="dataDetails.address" />

</view>
</view>
    <view   class='flex flex-wrap align-center justify-between editAddress_fd1_5'     >
        <text class='editAddress_fd1_5_c0' >设为默认地址</text>
<switch  color='rgba(0, 195, 75, 1)' style="transform: scale(0.8)" class="flex " :checked="dataDetails.is_default" />
</view>
</view>
<!---添加地址flex布局结束-->
<benben-popup v-model="popupShow1658111180390" :mask="true"  mode='center'>
    <!---删除地址flex布局开始-->
 <view class="flex flex-direction flex-wrap align-center editAddress_flex_2"   >
        <text class='editAddress_fd2_0' >提示</text>
<text class='editAddress_fd2_1' >确定删除该地址？</text>
    <view   class='flex flex-wrap align-center editAddress_fd2_2'     >
        <button class='editAddress_fd2_2_c0' @tap.stop="popupShow1658111180390=false"  >取消</button>
<button class='editAddress_fd2_2_c1' @tap.stop="DeteleAddressFunc()"  >确定</button>
</view>
</view>
<!---删除地址flex布局结束-->
</benben-popup>
    <view class="flex flex-wrap align-center justify-center benben-position-layout flex editAddress_flex_3"    >
        <button class='editAddress_fd3_0' @tap.stop="handleJumpDiy" data-type="back" data-url="1"  >保存</button>

        </view>
<view :style="{height: '88rpx'}"  ></view>
<!--选择所在地区开始 -->
        <benben-picker ref="benbenWritePickerCodepicker4" :visible.sync="pickerDiy1657266876127" :label.sync='dataDetails.address_detail' :province.sync='dataDetails.province_code' :city.sync='dataDetails.city_code' :area.sync='dataDetails.district_code'  mode='region' :mask-show='true' :picker-height='88' :hide-area='false' >
            <template #picker-header>
        <view   class='flex flex-wrap align-center justify-between editAddress_picker4_0'     >
        <text class='editAddress_picker4_0_c0' @tap="$refs.benbenWritePickerCodepicker4.cancel()" >取消</text>
<text class='editAddress_picker4_0_c1' >选择所在地区</text>
<text class='editAddress_picker4_0_c2' @tap="$refs.benbenWritePickerCodepicker4.pickerConfirm()" >确认</text>
</view>
</template>
        </benben-picker>
<!--选择所在地区结束 -->
    
    
    </view>
</template>
<script>
    import {validate} from '@/common/utils/validate.js'
    export default {
        components:{},
        
        
        data(){
			return {"pickerDiy1657266876127":false,"popupShow1658111180390":false,"sex":[{"name":"先生","value":"1","image":""},{"name":"女士","value":"2","image":""}],"label":[],"dataDetails":{"name":"","mobile":"","address":"","is_default":"","postal_code":"","province":"","city":"","district":"","sex":"","label_name":"","address_detail":"","province_code":"","city_code":"","district_code":""},"select_adr":[{"name":"公司","value":"1","image":""},{"name":"家","value":"2","image":""}],"address":"1","id":""};
		},
		computed:{
            themeColor() {
              return this.$store.getters.themeColor
            },
            
		},
		watch:{},
		onLoad(options){
            let {id}=options
if (id !== undefined) this.id = id
this.DataDetailsFunc()
		},
        onUnload() {
                
        },
		onReady(){
            
		},
		onShow(){
            
		},
		onHide(){
            
		},
		onResize(){
            
		},
		onPullDownRefresh(){
            
		},
		onReachBottom(e){
            
		},
		onPageScroll(e){
            
		},
		methods:{
                            //获取地址信息
                async DataDetailsFunc(){
                        //请求方法
    //数据验证
    
  let datadataDetails = await this.$api.post(global.apiUrls.post5cadc769e4f16, {
    address_id:this.id
  });
  if (datadataDetails.data.code != 1) {
    this.$message.info(datadataDetails.data.msg);
    return
  } 
  let infodataDetails = datadataDetails.data;
  this.dataDetails = infodataDetails.data
    //请求方法
    //数据验证
    
  let datalabel = await this.$api.post(global.apiUrls.post62d50ce5e3cc4, {
    
  });
  if (datalabel.data.code != 1) {
    this.$message.info(datalabel.data.msg);
    return
  } 
  let infolabel = datalabel.data;
  this.label = infolabel.data
                },
                //删除地址
                async DeteleAddressFunc(){
                        //请求方法
    //数据验证
    
  let data62d28c0eccdbf = await this.$api.post(global.apiUrls.post62d28c0eccdbf, {
    address_ids:this.id
  });
  if (data62d28c0eccdbf.data.code != 1) {
    this.$message.info(data62d28c0eccdbf.data.msg);
    return
  } 
  
  
    this.popupShow1658111180390 = false;
                setTimeout(()=>{
                    uni.navigateBack({
              delta:1
            });
      },1000)
                    this.$message.info('删除成功');
                },
                //提交
                async sumbitFunc(){
                                if(!validate(this.dataDetails.name,'require')){
                 this.$message.info('请输入收货人');
                 return false;
            }
            if(!validate(this.dataDetails.label_name,'require')){
                 this.$message.info('请选择标签');
                 return false;
            }
            if(!validate(this.dataDetails.mobile,'require')){
                 this.$message.info('请输入手机号');
                 return false;
            }

            if(!validate(this.dataDetails.province,'require')){
                 this.$message.info('请选择地址');
                 return false;
            }
            if(!validate(this.dataDetails.address,'require')){
                 this.$message.info('请输入详细地址');
                 return false;
            }
            if(!validate(this.dataDetails.mobile,'phone')){
                 this.$message.info('请输入正确的手机号');
                 return false;
            }
    //请求方法
    //数据验证
    
  let data62d51684b3a65 = await this.$api.post(global.apiUrls.post62d51684b3a65, {
    name:this.dataDetails.name,mobile:this.dataDetails.mobile,is_default:this.dataDetails.is_default,province_code:this.dataDetails.province_code,city_code:this.dataDetails.city_code,district_code:this.dataDetails.district_code,address:this.dataDetails.address,sex:this.dataDetails.sex,label_name:this.dataDetails.label_name,address_id:this.id
  });
  if (data62d51684b3a65.data.code != 1) {
    this.$message.info(data62d51684b3a65.data.msg);
    return
  } 
  
  
                setTimeout(()=>{
                    uni.navigateBack({
              delta:1
            });
      },1000)
                    this.$message.info('编辑成功');
                }
		}
    };
</script> 
<style lang="scss" scoped>
           .page{
            width: 100vw;
            overflow-x: hidden;
            min-height: calc(100vh - var(--window-bottom));
            background:#F8F8F8;background-size: 100% auto !important;
        }
    .editAddress_flex_0{
        border-bottom:1px solid #eee;background:#fff;width:750rpx;height:88rpx;overflow:hidden;z-index:10;top:0rpx;background-size:100% auto !important;
    }
    .editAddress_fd0_0_c2_c0{
        font-size:32rpx;font-weight:500;color:#333333;
    }
    .editAddress_fd0_0_c2{
        padding:0rpx 0rpx 0rpx 0rpx;width:200rpx;
    }
    .editAddress_fd0_0_c1_c0{
        font-size:36rpx;font-weight:500;color:#333333;
    }
    .editAddress_fd0_0_c0_c0{
        font-size:36rpx;color:#333;font-weight:500;
    }
    .editAddress_fd0_0_c0{
        width:200rpx;
    }
    .editAddress_fd0_0{
        padding:0rpx 32rpx 0rpx 32rpx;line-height:88rpx;
    }
    .editAddress_flex_1{
        background:#fff;background-size:100% auto !important;padding:0rpx 0rpx 0rpx 32rpx;
    }
    .editAddress_fd1_5_c0{
        font-size:32rpx;font-weight:400;color:#333333;
    }
    .editAddress_fd1_5{
        padding:32rpx 32rpx 32rpx 0rpx;
    }
    .editAddress_input_fd1_4_c0{
        font-size:28rpx;font-weight:400;color:#333;
    }
    .editAddress_fd1_4_c0{
        background:rgba(246, 246, 246, 1);width:680rpx;padding:24rpx 24rpx 24rpx 24rpx;border-radius:8rpx 8rpx 8rpx 8rpx;height:160rpx;
    }
    .editAddress_fd1_4{
        border-bottom:1px solid #eee;padding:32rpx 32rpx 32rpx 0rpx;
    }
    .editAddress_fd1_3_c2{
        width:14rpx;height:22rpx;
    }
    .editAddress_fd1_3_c1{
        padding:0rpx 0rpx 0rpx 40rpx;font-size:32rpx;font-weight:500;color:#333;line-height:45rpx;
    }
    .editAddress_fd1_3_c0{
        font-size:32rpx;font-weight:400;color:#333333;
    }
    .editAddress_fd1_3{
        border-bottom:1px solid #eee;padding:32rpx 32rpx 32rpx 0rpx;
    }
    .editAddress_fd1_2_c1{
        padding:0rpx 0rpx 0rpx 40rpx;font-size:32rpx;font-weight:500;color:#333;line-height:45rpx;
    }
    .editAddress_fd1_2_c0{
        font-size:32rpx;font-weight:400;color:#333333;
    }
    .editAddress_fd1_2{
        border-bottom:1px solid #eee;padding:32rpx 32rpx 32rpx 0rpx;
    }
    .editAddress_fd1_1_c2_c1_c1{
        font-size:32rpx;font-weight:400;color:#999999;margin:0rpx 0rpx 0rpx 12rpx;
    }
    .editAddress_fd1_1_c2_c1_c0{
        width:36rpx;height:36rpx;
    }
    .editAddress_fd1_1_c2_c1{
        margin:0rpx 32rpx 0rpx 0rpx;
    }
    .editAddress_fd1_1_c2_c0_c1{
        font-size:32rpx;font-weight:400;color:#333333;margin:0rpx 0rpx 0rpx 12rpx;
    }
    .editAddress_fd1_1_c2_c0_c0{
        width:36rpx;height:36rpx;
    }
    .editAddress_fd1_1_c2_c0{
        margin:0rpx 32rpx 0rpx 0rpx;
    }
    .editAddress_fd1_1_c1{
        padding:0rpx 0rpx 0rpx 72rpx;font-size:32rpx;font-weight:400;color:#333;line-height:45rpx;
    }
    .editAddress_fd1_1_c0{
        font-size:32rpx;font-weight:400;color:#333333;
    }
    .editAddress_fd1_1{
        border-bottom:1px solid #eee;padding:32rpx 0rpx 32rpx 0rpx;
    }
    .editAddress_fd1_0_c1_c1_c0{
        border:1px solid rgba(229, 229, 229, 1);background:#fff;margin:0rpx 16rpx 0rpx 0rpx;border-radius:5rpx 5rpx 5rpx 5rpx;font-size:24rpx;font-weight:400;color:#333;padding:4rpx 12rpx 4rpx 12rpx;
    }
    .editAddress_fd1_0_c1_c0_c0{
        border:1px solid rgba(42, 42, 42, 1);margin:0rpx 16rpx 0rpx 0rpx;border-radius:5rpx 5rpx 5rpx 5rpx;font-size:24rpx;font-weight:400;color:rgba(42, 42, 42, 1);padding:4rpx 12rpx 4rpx 12rpx;
    }
    .editAddress_fd1_0_c0{
        font-size:32rpx;font-weight:400;color:#333333;margin:0rpx 101rpx 0rpx 0rpx;
    }
    .editAddress_fd1_0{
        border-bottom:1px solid #eee;padding:32rpx 32rpx 32rpx 0rpx;
    }
    .editAddress_flex_2{
        background:#fff;margin:0rpx 105rpx 0rpx 105rpx;background-size:#eee;border-radius:16rpx 16rpx 16rpx 16rpx;padding:32rpx 0rpx 0rpx 0rpx;
    }
    .editAddress_fd2_2_c1{
        background:transparent;line-height:45rpx;border-radius:0rpx 0rpx 16rpx 0rpx;font-size:32rpx;color:rgba(62, 128, 246, 1);padding:24rpx 103rpx 24rpx 99rpx;
    }
    .editAddress_fd2_2_c0{
        border-right:1px solid #EEEEEE;background:transparent;line-height:45rpx;border-radius:0rpx 0rpx 0rpx 16rpx;font-size:32rpx;color:rgba(153, 153, 153, 1);padding:24rpx 103rpx 24rpx 103rpx;
    }
    .editAddress_fd2_2{
        border-top:1px solid #eee;
    }
    .editAddress_fd2_1{
        font-size:28rpx;line-height:52rpx;font-weight:400;color:#333333;margin:40rpx 0rpx 40rpx 0rpx;
    }
    .editAddress_fd2_0{
        font-weight:500;font-size:32rpx;color:#333333;
    }
    .editAddress_flex_3{
        width:750rpx;height:88rpx;overflow:hidden;z-index:10;bottom:calc(56rpx + var(--window-bottom));
    }
    .editAddress_fd3_0{
        background:rgba(255, 255, 255, 1);border-radius:100rpx 100rpx 100rpx 100rpx;font-size:32rpx;color:rgba(42, 42, 42, 1);width:686rpx;height:88rpx;line-height:88rpx;font-weight:500;
    }
    .editAddress_picker4_0_c2{
        color:var(--benbenFontColor0);line-height:40rpx;font-size:32rpx;font-weight:500;
    }
    .editAddress_picker4_0_c1{
        font-size:32rpx;font-weight:400;color:#333333;
    }
    .editAddress_picker4_0_c0{
        line-height:40rpx;font-size:32rpx;font-weight:500;color:#BFBFBF;
    }
    .editAddress_picker4_0{
        border-bottom:1px solid #eee;background:#fff;padding:0rpx 32rpx 0rpx 32rpx;line-height:110rpx;border-radius:25rpx 25rpx 0rpx 0rpx;background-size:100% auto !important;
    }
</style>